﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace AddItemToProducts
{
    class TaskSeven
    {
        private SqlCommand dbCon;


        public void Insert()
        {
            SqlConnection dbCon = new SqlConnection("Server=.\\SQLEXPRESS; " +
                "Database=Northwind; Integrated Security=true");
            dbCon.Open();
            using (dbCon)
            {
                SqlCommand cmd = new SqlCommand(
                    "INSERT INTO Products(ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice," +
                    "UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued) " +
                    "VALUES(@productName, @supplierID, @categoryID, @quantityPerUnit, @unitPrice, @unitsInStock," +
                    "@unitsOnOrder, @reorderLevel, @discontinued)", dbCon);

                string productName = "NewTestProduct";
                int supplierID = 1;
                int categoryID = 1;
                string quantityPerUnit = "what quantity?";
                decimal unitPrice = 10;
                int unitsInStock = 10;
                int unitsOnOrder = 20;
                int reorderLevel = 0;
                int discontinued = 0;

                cmd.Parameters.Add(new SqlParameter("@productName", productName));
                cmd.Parameters.Add(new SqlParameter("@supplierID", supplierID));
                cmd.Parameters.Add(new SqlParameter("@categoryID", categoryID));
                cmd.Parameters.Add(new SqlParameter("@quantityPerUnit", quantityPerUnit));
                cmd.Parameters.Add(new SqlParameter("@unitPrice", unitPrice));
                cmd.Parameters.Add(new SqlParameter("@unitsInStock", unitsInStock));
                cmd.Parameters.Add(new SqlParameter("@unitsOnOrder", unitsOnOrder));
                cmd.Parameters.Add(new SqlParameter("@reorderLevel", reorderLevel));
                cmd.Parameters.Add(new SqlParameter("@discontinued", discontinued));

                cmd.ExecuteNonQuery();
            }
        }

        static void Main(string[] args)
        {
            TaskSeven task = new TaskSeven();
            task.Insert();

        }
    }
}
